package cn.xuewenbao.edu.service.impl;

import cn.xuewenbao.edu.entity.ColumnType;
import cn.xuewenbao.edu.entity.vo.MyLikeOrFavoriteContentVo;
import cn.xuewenbao.edu.mapper.ColumnTypeMapper;
import cn.xuewenbao.edu.service.ColumnTypeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 专栏名称表 服务实现类
 * </p>
 *
 * @author mafayu
 * @since 2021-04-19
 */
@Service
public class ColumnTypeServiceImpl extends ServiceImpl<ColumnTypeMapper, ColumnType> implements ColumnTypeService {

    @Autowired
    private ColumnTypeMapper columnTypeMapper;

    @Override
    public String getColumnTypeById(String columnTypeId) {
        ColumnType columnType = baseMapper.selectById(columnTypeId);
        if (columnType != null) {
            return columnType.getColumnValue();
        } else {
            return null;
        }
    }

    //获取 专栏内容的 title cover viewCount
    @Override
    public MyLikeOrFavoriteContentVo selectMyLikeOrFavoriteContent(String contentId, String tableName) {
        if ("journal_subject".equals(tableName)) {
            return columnTypeMapper.selectSubTitleNumberViewCount(contentId, tableName);
        } else if ("course".equals(tableName)){
            return columnTypeMapper.selectTitleCoverBuyCount(contentId, tableName);
        } else if ("article".equals(tableName)){
            return columnTypeMapper.selectTitleCoverViewCount(contentId, tableName);
        }else {
            return columnTypeMapper.selectTitleCoverDesciptionViewCount(contentId, tableName);
        }
    }
}
